
function init(){
	//设备状态下拉框
	$(".status").click(function(event){
	    event.stopPropagation();
	    dropdown($(".down_menu"),$(".status"));
	});
	//用户信息查询下拉框
	$(".write_box").click(function(event){
		event.stopPropagation();
		dropdown($(".userIds"),$(".write_box"))
	});
	//用户信息表格偶数行背景变色
	$(".userinfo_tab tbody tr:odd").css("backgroundColor","#F6F6F6");
	//选择性别(edit)
	$(".sex_edit").click(function(event){
	    event.stopPropagation();
	    dropdown($(".sex_e"),$(".sex_edit"));
	});
	//选择性别(add)
	$(".sex_add").click(function(event){
	    event.stopPropagation();
	    dropdown($(".sex_a"),$(".sex_add"));
	});
	function dropdown(down_box,sex_box){
	    $(down_box).slideDown();
	    $(down_box).children("a").unbind("click").click(function(){
	        $(sex_box).html($(this).html());
	    });
	    $("body").click(function(){
	        $(down_box).slideUp();
	    });
	}

	//左侧按钮切换
	$(".side_left a").click(function(){
	    var $aImg_w=["11.png","21.png","31.png","71.png","81.png"];
	    var $aImg_b=["12.png","22.png","32.png","72.png","82.png"];
	    $(this).addClass("list_active").siblings().removeClass("list_active");

	    for(var i=0;i<$aImg_b.length;i++)
	    {
	        $(".side_left a").eq(i).children("span").css("background","url(/img/admin_pc/"+$aImg_w[i]+") no-repeat");
	        $(".side_right").removeClass("disactive");
	    }
	    $(this).children("span").css("background","url(/img/admin_pc/"+$aImg_b[$(this).index()-1]+") no-repeat");
	});
	$(".side_left > a").focus(function(){
	    $(this).blur();
	})

	//删除账户
	$(".delete_btn").click(function(){
	    var _this=$(this);
	    var username=$(this).parent().parent().children().eq(0).html();
	    $('.hint_page').css("display","block");
	    $('.hint_page').height($(window).height());
	    $('.hint_txt').html("确定删除该账号吗？");
	    $('.hint_no').unbind("click").click(function(){
	        $('.hint_page').css("display","none");
	    });
	    $('.hint_yes').unbind().click(function(){
	        $.ajax({
	            url:"/api/admin/delete",
	            type:"post",
	            dataType:"json",
	            data:{username:username},
	            success:function(data){
	                if(data.status['errCode'] == 0){
	                    _this.parent().parent().remove();
	                    $('.hint_page').css("display","none");
	                    hint("删除成功！");
	                     
	                }else{
	                    hint(data.status.message);
	                }
	            },
	            error:function(jqXHR, textStatus, errorThrown){
	                hint(jqXHR.responseText);
	            }
	        });
	    });
	});

	//退出登录
	$('.bowout_btn').click(function(){
	    $.ajax({
	        url:'/api/admin/logout',
	        type:'post',
	        success:function(data){
	            if(data.status.errCode == 0){
	                window.location.href = '/admin/user/login';
	            }
	        }
	    });
	});
	//用户编号查询
	$(".write_box").click(function(){
		var nameBox1=$(".name_txt1");
		var telBox1=$(".tel_txt1");
		var _this=$(this);
		nameBox1.html("");
		telBox1.html("");
	    $(".userIds").css("display","block");
	    $(".userIds a").unbind("click").click(function(){
	        _this.html($(this).html());
	        $(".userIds").css("display","none");
	        $.ajax({
	            url:"/api/admin/user/info",
	            type:"get",
	            dataType:"json",
	            data:{
	                openId:$(this).html()
	            },
	            success:function(data){
	                if(data.status['errCode'] == 0){
	                    nameBox1.html(data.data.userInfo.name);
	                    telBox1.html(data.data.userInfo.phone);
	                }else{
	                 
	                }
	            },
	            error:function(jqXHR, textStatus, errorThrown){
	                hint(jqXHR.responseText);
	            }
	        });
	    });
	});
	//设置文本框提示文本显示与隐藏
   $("input").each(function(){
     var thisVal=$(this).val();
     //判断文本框的值是否为空，有值的情况就隐藏提示语，没有值就显示
     if(thisVal!=""){
       $(this).siblings("span").hide();
      }else{
       $(this).siblings("span").show();
      }
     //聚焦型输入框验证 
     $(this).focus(function(){
       $(this).siblings("span").hide();
      }).blur(function(){
        var val=$(this).val();
        if(val!=""){
         $(this).siblings("span").hide();
        }else{
         $(this).siblings("span").show();
        } 
      });
    })
    $("input").each(function(){
     var thisVal=$(this).val();
     //判断文本框的值是否为空，有值的情况就隐藏提示语，没有值就显示
     if(thisVal!=""){
       $(this).siblings("span").hide();
      }else{
       $(this).siblings("span").show();
      }
      $(this).keyup(function(){
       var val=$(this).val();
       $(this).siblings("span").hide();
      }).blur(function(){
        var val=$(this).val();
        if(val!=""){
         $(this).siblings("span").hide();
        }else{
         $(this).siblings("span").show();
        }
       })
     }) 

}

function hint(hint){
    if(hint)
    {
        $('.hint_bg').height($(window).height());
        $('.hint_bg').css("display","block");
        $('.hint_text').html(hint);
        $('.hint_btn').click(function(){
            $('.hint_bg').css("display","none");
        });
    }
}
function hint1(hint1){
    if(hint1)
    {
        $('.hint_bg1').height($(window).height());
        $('.hint_bg1').css("display","block");
        $('.hint_text1').html(hint1);
        
    }
}
 








